package com.example.zlx.service.impl;

import com.example.zlx.entity.Economic;
import com.example.zlx.repository.EconomicRepository;
import com.example.zlx.service.EconomicService;
import com.example.zlx.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EconomicServiceImpl  implements EconomicService{
    @Autowired
    private EconomicRepository economicRepository;
    @Override
    public ServerResponse<Economic> getEconomicById(Integer id) {
        Economic economicInfo=economicRepository.findOne(id);
        if(economicInfo==null){
            return ServerResponse.createByErrorMessage("没有相应的id");
        }
        return ServerResponse.createBySuccess("查找成功",economicInfo);
    }

    @Override
    public ServerResponse listAll() {
        List<Economic> list= economicRepository.findAll();
        return ServerResponse.createBySuccess(list);
    }
}
